export default {
  namespaced: true,
  state: {
    isShowToast: false,
    toastMsg: "",
    toastType: "",
  },

  mutations: {
    changeIsIsShowToast(state, payload) {
      state.isShowToast = payload.isShow;
      if (payload.isShow) {
        state.toastMsg = payload.msg;
        state.toastType = payload.type;
      }
    },
  },
  actions: {
    asyncChangeIsShowToast(context, payload) {
      context.commit("changeIsIsShowToast", {
        isShow: true,
        msg: payload.msg,
        type: payload.type,
      });
      // 定时关闭提示
      setTimeout(() => {
        context.commit("changeIsIsShowToast", {
          isShow: false,
        });
      }, 1500);
    },
  },
};
